package br.com.felix.fwt.ui.css;

import java.io.PrintWriter;
import java.io.Serializable;

import br.com.felix.fwt.servlet.FelixWebToolkitServlet;
import br.com.felix.fwt.ui.Renderable;

/**
 * The Class ExternalCSS is a utility class to define a reference to a external cascade style sheet.
 */
public class ExternalCSS implements Serializable, Renderable{

	private static final long serialVersionUID = -6554607732655028301L;
	
	/** The path to the css file. */
	public String path;
	
	/**
	 * Instantiates a new external css.
	 * 
	 * @param path the path of the css file. You may use a relative or an absolute path. No checking is made.
	 */
	public ExternalCSS(String path){
		this.path = path;
	}
	
	
	/**
	 * This method prints the HTML declaration of the External CSS.
	 * 
	 * @return the string with the proper HTML code.
	 */
	public void write(PrintWriter out){
		out.write("<link rel=\"stylesheet\" type=\"text/css\" href=\"");
		out.write(FelixWebToolkitServlet.getFwtContext().request.getContextPath());
		out.write(path);
		out.write("\" />");
	}
	
}
